<template>
<div>
    <el-container>
        <el-header>Header</el-header>
        <el-container>
            <el-aside width="200px">
                <el-menu class="el-menu-vertical-demo" background-color="#ffffff" text-color="#303133" active-text-color="#409eff" :unique-opened="true" :default-active="$route.path" :router="true">
                    <template v-for="(menuItem,menuIndex) in navList">
              <!-- <el-submenu :key="menuIndex" :index="String(menuIndex)" v-if="menuItem.children.length>0">
              <template slot="title">
                <i :class="'iconfont '+menuItem.icon"></i>
                <span>{{menuItem.title}}</span>
</template>
<template>
<el-menu-item :index="String(childItem.href)" v-for="(childItem, childIndex) in menuItem.children" :key="childIndex">
    {{childItem.title}}</el-menu-item>
</template>
        </el-submenu> -->
              <el-menu-item :index="menuItem.path" :key="menuIndex" v-if="menuItem.meta.nav">
                <i :class="'iconfont '+menuItem.icon"></i>
                <span slot="title">{{menuItem.name}}</span>
              </el-menu-item>
            </template>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
    data() {
        return {};
    },
    mounted() {
        // console.log(this.$store)
    },
    methods: {
        handleOpen(key, keyPath) {
            console.log(key, keyPath);
        },
        handleClose(key, keyPath) {
            console.log(key, keyPath);
        }
    },
    computed: {
        ...mapState({
            navList: function(state) {
                if (this.info.userType) {
                    console.log(state.navList[0].children);
                    return state.navList[0].children;
                }
            },
            info: function(state) {
                return state.userInfo;
            }
        })
    }
};
</script>
<style>
.el-header,
.el-footer {
    background-color: #b3c0d1;
    color: #333;
    text-align: center;
    line-height: 60px;
}

.el-aside {
    background-color: #d3dce6;
    color: #333;
    text-align: center;
    line-height: 200px;
}

.el-main {
    background-color: #e9eef3;
    color: #333;
    text-align: center;
    line-height: 160px;
}
</style>